package com.anyou.mall.index.controller;

import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.core.page.TableDataInfo;
import com.anyou.common.enums.BusinessType;
import com.anyou.common.exception.ServiceException;
import com.anyou.common.utils.poi.ExcelUtil;

import com.anyou.mall.index.param.CarPartsShopParam;
import com.anyou.mall.index.param.OrderNumParam;
import com.anyou.mall.index.param.ShopCertMsgParam;
import com.anyou.mall.index.param.ShopParam;
import com.anyou.mall.index.vo.Card6Vo;
import com.anyou.mall.index.vo.OrderNumTjVo;
import com.anyou.mall.index.vo.ShopOrderMoneyVo;
import com.anyou.mall.order.service.IOrdOrderService;
import com.anyou.mall.pla.service.IPlaCarPartsCityService;
import com.anyou.mall.sho.domain.CarPartsShopAudit;
import com.anyou.mall.sho.domain.ShopNotice;
import com.anyou.mall.sho.service.ICarPartsShopService;
import com.anyou.mall.sho.service.IShopNoticeService;
import com.anyou.mall.sho.vo.CarPartsShopDetailsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * 商家首页Controller
 *
 * @author gaochaohao
 * @date 2022-04-02
 */
@Api(tags = "商家首页")
@RestController
@RequestMapping("/shop/index")
public class ShopIndexController extends BaseController
{

    @Autowired
    private ICarPartsShopService carPartsShopService;

    @Autowired
    private IShopNoticeService shopNoticeService;


    @Autowired
    private IPlaCarPartsCityService carPartsCityService;
    @Autowired
    private IOrdOrderService ordOrderService;


//    /**
//     * 商家店铺信息
//     */
//    @ApiOperation("商家店铺信息")
//    @PreAuthorize("@ss.hasPermi('shop:index:shopInfo')")
//    @PostMapping("/shopInfo")
//    public ApiResult<CarPartsShopDetailsVo> shopInfo(@Valid @RequestBody ShopParam shopParam) {
//        CarPartsShopDetailsVo carPartsShopDetailsVo = carPartsShopService.selectCarPartsShopDetailsByCarPartsShopId(shopParam.getCarPartsShopId());
//        return ApiResult.success(carPartsShopDetailsVo);
//    }

//    /**
//     * 商家认证消息列表
//     */
//    @ApiOperation("商家认证消息列表")
//    @PreAuthorize("@ss.hasPermi('shop:index:certMsg')")
//    @GetMapping("/certMsgList")
//    public TableDataInfo<List<ShopNotice>> list(ShopCertMsgParam shopCertMsgParam)
//    {
//        ShopNotice shopNotice = new ShopNotice();
//        shopNotice.setCarPartsShopId(shopCertMsgParam.getCarPartsShopId());
//        shopNotice.setNoticeType(0);
//        shopNotice.setSystemType(3);
//        startPage();
//        List<ShopNotice> list = shopNoticeService.selectShopNoticeList(shopNotice);
//        return getDataTable(list);
//    }

//    /**
//     * 商家店铺修改
//     */
//    @ApiOperation("商家店铺修改")
//    @PreAuthorize("@ss.hasPermi('shop:index:update')")
//    @PostMapping("/update")
//    public ApiResult update(@Valid @RequestBody CarPartsShopParam carPartsShopParam) {
//        CarPartsShopAudit carPartsShopAudit = new CarPartsShopAudit();
//        BeanUtils.copyProperties(carPartsShopParam,carPartsShopAudit);
//        return carPartsShopService.shopAdminUpdate(carPartsShopAudit);
//    }

    /**
     * 6个卡片的数量
     */
    @ApiOperation("6个卡片的数量")
    @PreAuthorize("@ss.hasPermi('shop:index:card6')")
    @PostMapping("/card6")
    public ApiResult<Card6Vo> card6(@Valid @RequestBody ShopParam shopParam) {
        return carPartsShopService.card6(shopParam);
    }

    /**
     * 商品销售金额折线走势图
     */
    @ApiOperation("商品销售金额折线走势图")
    @PreAuthorize("@ss.hasPermi('shop:index:orderMoney')")
    @PostMapping("/orderMoney")
    public ApiResult<List<OrderNumTjVo>> orderMoney(@Valid @RequestBody OrderNumParam orderNumParam) {
        List<OrderNumTjVo> list=ordOrderService.getTotalMoney2(orderNumParam);
        return ApiResult.success(list);
    }
    /**
     * 商品订单量折线走势图
     */
    @ApiOperation("商品订单量折线走势图")
    @PreAuthorize("@ss.hasPermi('shop:index:orderNum')")
    @PostMapping("/ordeNnum")
    public ApiResult<List<OrderNumTjVo>> orderNum(@Valid @RequestBody OrderNumParam orderNumParam) {
        return ordOrderService.orderNumTj(orderNumParam);
    }
}
